package tetris;
import java.awt.*;

public class Gamewin {
    boolean[][] win = new boolean[10][20];
    boolean playover=false;
    float[][][] gamergb =new float[10][20][4];
    int once=0;
    Gameline[] gameline = new Gameline[20];
    public class Gameline extends Canvas{
        public int h;                                  //记录第几行，即高度
//        public void Gameline(){
//            setBackground(Color.green);
//            for (int s=0;s<=9;s++){
//                win[s][h]=true;
//                gamergb[s][h][0]=0f;gamergb[s][h][1]=0.9f;
//                gamergb[s][h][2]=0f;gamergb[s][h][3]=1f;
//                }
//        }

        public void paint(Graphics g){
          for (int i=0;i<=200;i=i+20){
                g.setColor(Color.darkGray );
                g.drawLine(i, 0, i, 20);
            }
            for (int j=0;j<=20;j=j+20){
                g.setColor(Color.darkGray);
                g.drawLine(0, j, 200, j);
            }
            for (int s=0;s<=9;s++){
                    if (win[s][h]==false){
                        g.setColor(new Color(gamergb[s][h][0],gamergb[s][h][1],gamergb[s][h][2],gamergb[s][h][3]));
                        g.fill3DRect(s*20,0,20,20,true);
                }
            }
        }
    }
    public Gamewin(){
            for(int u=0;u<=19;u++){
                    gameline[u] = new Gameline();
                    gameline[u].setSize(200, 20);
                    gameline[u].h=u;
            }
        }
    public void drawline(int y1,int y2){
        for (int u=y1;u>=y2;u--){
            gameline[u].repaint();
        }
    }
    public void gameover(){
        for (int u=0;u<=19;u++)
            for (int v=0;v<=9;v++){
                win[v][u]=true;
            }
        int[][] over = {
            {1,3},{1,4},{1,5},{1,6},
            {2,3},{2,6},
            {3,3},{3,6},
            {4,3},{4,4},{4,5},{4,6},

            {6,3},{6,6},
            {7,4},{7,5},

            {9,3},{9,4},{9,5},{9,6},
            {10,3},
            {11,3},{11,4},{11,5},{11,6},
            {12,3},
            {13,3},{13,4},{13,5},{13,6},
            
            {15,3},{15,4},{15,5},
            {16,3},{16,5},
            {17,3},{17,4},{17,5},
            {18,3},{18,5},{18,6}
        };
        for (int u=0;u<=40;u++){
            win[over[u][1]][over[u][0]]=false;
            gamergb[over[u][1]][over[u][0]][0]=1f;
            gamergb[over[u][1]][over[u][0]][1]=0.2f;
            gamergb[over[u][1]][over[u][0]][2]=1f;
            gamergb[over[u][1]][over[u][0]][3]=1f;
        }
        drawline(19,0);
    }
}